class_name Section
extends RefCounted

var section_code:int
var empty:bool = true
var blocks:PackedInt32Array
var mesh_node:MeshInstance3D
var bottom_height: int =0

func _init() -> void:
	blocks.resize(16*16*16)
	blocks.fill(0)

func update_empty():
	for i in blocks:
		if i!=0:
			empty=false
	return

func get_inner_block(p_pos:Vector3):
	var inner_id:int = p_pos.x+ p_pos.y*Data.section_size+ p_pos.z*Data.section_size*Data.section_size
	return blocks[inner_id]

func set_inner_block(p_pos:Vector3,p_block_type:int):
	var inner_id:int = p_pos.x+ p_pos.y*Data.section_size+ p_pos.z*Data.section_size*Data.section_size
	blocks[inner_id] = p_block_type
